/*
 * CDPSWeapon.java
 * 
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 * 
 * This file is part of JRogueDPS.
 * 
 * JRogueDPS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JRogueDPS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with JRogueDPS.  If not, see <http://www.gnu.org/licenses/>.
 */

package dpsinterface;

import dpssystem.CPoison.PoisonType;
import dpssystem.CWeapon.WeaponType;
import geardatabase.CItemType.ItemType;
import geardatabase.CProcItem;
import jroguedps.CGlobal;
import paperdoll.CDollSlot;
import paperdoll.CDollSlotType.DollSlotType;

/**
 *
 * @author Giles Millward (Manigra)
 */
public class CDPSWeapon {
    private String m_name;
    private double m_minDamage;
    private double m_maxDamage;
    private double m_weaponSpeed;
    private double m_modifier;
    private PoisonType m_poisonType;
    private WeaponType m_weaponType;
    private CProcItem m_procItem = null;

    CDPSWeapon (CDPSTalents p_talents, boolean p_mh)
    {
        CDollSlot l_slot;

        if (p_mh)
        {
            l_slot = CGlobal.g_paperDoll.getSlot(DollSlotType.MAINHAND);
            m_modifier = 1.0;
        }
        else
        {
            l_slot = CGlobal.g_paperDoll.getSlot(DollSlotType.OFFHAND);
            m_modifier = 0.5 + (p_talents.getDualWieldSpecializationDouble() * 5);
        }

        m_maxDamage = l_slot.getItem().getMaxWeaponDamage();
        m_minDamage = l_slot.getItem().getMinWeaponDamage();
        m_weaponSpeed = l_slot.getItem().getWeaponSpeed();
        m_name = l_slot.getItem().getName();
        if (l_slot.getEnchant() != null)
        {
            // Find proc item for this weapon (think beserking, mongoose etc)
            m_procItem = CGlobal.g_procDatabase.getProcItem(l_slot.getEnchant().getId());
        }

        if (l_slot.getItem().getItemType() == ItemType.MACE)
        {
            m_weaponType = WeaponType.MACE;
        } else if (l_slot.getItem().getItemType() == ItemType.SWORD)
        {
            m_weaponType = WeaponType.SWORD;
        } else if (l_slot.getItem().getItemType() == ItemType.AXE)
        {
            m_weaponType = WeaponType.AXE;
        } else if (l_slot.getItem().getItemType() == ItemType.FIST)
        {
            m_weaponType = WeaponType.FIST;
        } else if (l_slot.getItem().getItemType() == ItemType.DAGGER)
        {
            m_weaponType = WeaponType.DAGGER;
        }

        m_poisonType = PoisonType.NONE;
        if (l_slot.getPoison() != null)
        {
            int l_poisonId = l_slot.getPoison().getId();
            if (l_poisonId == 43233)
            {
                m_poisonType = PoisonType.DEADLY;
            } else if (l_poisonId == 43235)
            {
                m_poisonType = PoisonType.WOUND;
            } else if (l_poisonId == 43231)
            {
                m_poisonType = PoisonType.INSTANT;
            } else if (l_poisonId == 43237)
            {
                m_poisonType = PoisonType.ANESTHETIC;
            }
        }
    }

    /**
     * @return the m_name
     */
    public String getName() {
        return m_name;
    }

    /**
     * @return the m_minDamage
     */
    public double getMinDamage() {
        return m_minDamage;
    }

    /**
     * @return the m_maxDamage
     */
    public double getMaxDamage() {
        return m_maxDamage;
    }

    /**
     * @return the m_weaponSpeed
     */
    public double getWeaponSpeed() {
        return m_weaponSpeed;
    }

    /**
     * @return the m_modifier
     */
    public double getModifier() {
        return m_modifier;
    }

    /**
     * @return the m_poisonType
     */
    public PoisonType getPoisonType() {
        return m_poisonType;
    }

    /**
     * @return the m_weaponType
     */
    public WeaponType getWeaponType() {
        return m_weaponType;
    }

    public CProcItem getProcItem() {
        return this.m_procItem;
    }
}
